/*所有文件公用*/

// findIndex 替代函数  --权限查询专用
function findIndex(arr, val) {
    var searchIndex = -1;
    arr.filter(function (item, index) {
        if (item.resourceType == 1) {
            if (item.url.indexOf(val) != -1) {
                searchIndex = index;
                return item
            }
        }
    })
    return searchIndex
}

// 获取url参数的函数
function getQueryString(name) {
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    var r = window.location.search.substr(1).match(reg);
    if (r != null) {
        return unescape(r[2]);
    }
    return null;
}

// 日期格式转换
function getTime(res, num, sign) {
    var time = Date.parse(res)
    var odate = new Date(time);
    var year = odate.getFullYear();
    var month = odate.getMonth() + 1;
    var day = odate.getDate();
    var hours = odate.getHours();
    var minutes = odate.getMinutes();
    var seconds = odate.getSeconds();
    var arr = [year, month, day, hours, minutes, seconds];
    arr = arr.map(function (item) {
        if (item < 10) {
            item = '0' + item
        }
        return item
    })
    if (num <= 3) {
        var str = arr.slice(0, num).join(sign);
    } else {
        var str = arr.slice(0, 3).join(sign) + ' ' + arr[3];
        var len = num;
        for (var i = 4; i < len; i++) {
            str += ':' + arr[i];
        }
    }

    return str
}

// 本地存储封装
var Storage = {};
Storage.get = function (name) {
    return JSON.parse(localStorage.getItem(name))
};
Storage.set = function (name, val) {
    localStorage.setItem(name, JSON.stringify(val))
};
Storage.add = function (name, addVal) {
    var oldVal = Storage.get(name);
    var newVal = oldVal.concat(addVal);
    Storage.set(name, newVal)
};

function formatMoney(s, n) {
    if (s == undefined || s == "") {
        return "0.00"
    }
    n = n >= 0 && n <= 20 ? n : 2;
    s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
    var l = s.split(".")[0].split("").reverse(),
        r = s.split(".")[1],
        i, t = "";
    for (i = 0; i < l.length; i++) {
        t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "")
    }
    return t.split("").reverse().join("") + (r ? "." + r : "")
}

// 本地开发环境连接
var httpUrl = "http://127.0.0.1:8192/"; //检测权限
var httpUrl3 = "http://localhost/pc-web-etcpark/"; //检测权限 
var imgUrl = "https://10.9.4.210/pc-fs/";
// 开发地址
// var httpUrl3 = "http://10.9.4.210/pc-web-etcpark/"; //检测权限 
// var httpUrl = "http://10.9.4.210/pc-web-etcpark/admin/"; //检测权限 
// var imgUrl = "https://10.9.4.210/pc-fs/";


// 公共参数
var publicData = {};
// header 传参
var headData = {};
var token = Storage.get('token');
headData.token = token;
